<?php

class DropDownList extends PageElement
{
	private $options = array();
	private $selectedValue;

	public function __construct()
	{
	}

	public function setSelectedValue($arrayValue)
	{
		$this->selectedValue = $arrayValue;
	}

	public function setOptions($Options)
	{
		$this->options = $Options;
	}

	public function addOption($DDLOption)
	{
		array_push($this->options,$DDLOption);
	}

	public function getHTML()
	{
		$html = "<select".parent::getHTML().">\n";


		foreach($this->options as $SerializedOption)
		{
			$option = $SerializedOption;
			$selectedText = ($option->getValue()==$this->selectedValue)?" selected ".$option->getValue()." ":"";
			$html .= "<option value=\"".$option->getValue()."\"".$selectedText.">".$option->getText()."</option>\n";
		}
		$html .= "</select>\n";
		return $html;
	}

}

?>
